<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
	<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	<title>确认订单</title>
	<link rel="stylesheet" type="text/css" href="../../css/aui-flex.css" />
	<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
	<link rel="stylesheet" type="text/css" href="../../css/common.css" />
	<style>
		body {
			background: #F3F6F8;
		}

		.addrSec {
			padding: 0.75rem 1rem;
			margin-bottom: 0.4rem;
		}

		.address {
			padding-left: 1rem;
			padding-right: 2.2rem;
			min-height: 4rem;
		}

		.con {
			position: relative;
			color: #010101;
			font-size: 0.7rem;
		}

		.con:before {
			content: "";
			position: absolute;
			left: -1rem;
			top: 0.1rem;
			width: 0.68rem;
			height: 0.75rem;
			background: url(../../image/common/32.png) no-repeat;
			background-size: auto 0.75rem;
		}

		.addr {
			position: relative;
			margin-top: 0.8rem;
			color: #373336;
			font-size: 0.6rem;
			line-height: 20px;
		}

		.addr:before {
			content: "";
			position: absolute;
			left: -1rem;
			top: 0.1rem;
			width: 0.65rem;
			height: 0.75rem;
			background: url(../../image/common/33.png) no-repeat;
			background-size: auto 0.75rem;
		}

		.address .def {
			position: relative;
			top: -0.1rem;
			margin-left: 0.5rem;
			display: inline-block;
			font-size: 0.5rem;
			height: 0.8rem;
			line-height: 0.8rem;
			border-radius: 0.2rem;
			text-align: center;
			width: 1.45rem;
			vertical-align: middle;
		}

		.shop {
			padding-top: 0.8rem;
		}

		.shop .item {
			padding: 0rem 1rem 0.6rem;
		}

		.shop .media {
			width: 3.6rem;
		}

		.textBox {
			min-height: 4.5rem;
			padding-left: 0.5rem;
		}

		.comBox {
			margin-bottom: 0.4rem;
			padding: 0.5rem 0.8rem;
		}

		.comBox .comMode {
			font-size: 0.6rem;
			padding: 0.25rem 0;
		}
		button{
			padding: 0;
			background: none;
		}
		.copy {
			width: 1.8rem;
			height: 0.9rem;
			line-height: 0.9rem;
			border-radius: 2px;
			border: 1px solid #FFA565;
			color: #ff8028;
			font-size: 0.5rem;
			text-align: center;
			margin-top: 0.2rem;
		}
		.comU {
			padding-top: 0.7rem;
			padding-bottom: 0.8rem;
		}

		.titleBox {
			position: fixed;
			top: 0;
			width: 100%;
			z-index: 10;
			padding: 0 0.8rem;
			height: 3.2rem;
			background: #FFF1E5;
			color: #FF9850;
		}

		.black {
			height: 3.2rem;
		}

		.icon {
			margin-right: 0.4rem;
			height: 1.2rem;
		}

		.info-list {
			/*padding: 0.75rem 0.5rem;*/
		}

		.info-list li:nth-child(1) {
			padding-top: 0;
		}

		.info-list li {
			line-height: 28px;
		}

		.info-list li p {
			color: #555;
			font-size: 0.6rem;
		}

		.ped-r-6 {
			padding-right: 0.6rem;
		}
	.footerBox{
		position: fixed;
		width: 100%;
		height: 2.4rem;
		background: #fff;
		bottom: 0;
		box-shadow: 0px -0.1rem 0.2rem 0px rgba(0, 0, 0, 0.2);
		padding: 0 1rem;
	}
	.footerBox .fotBtn{
		width: 3.6rem;
		text-align: center;
		height: 1.4rem;
		line-height: 1.4rem;
		color: #adadad;
		border: 1px solid #adadad;
		border-radius: 5rem;
	}
	.footerBox .fotBtn.on{
		border: 1px solid #E73250 !important;
		color: #E73250;
		margin-left: 0.8rem;
	}
	</style>
</head>

<body>
		<!-- <div class="aui-font-size-12">剩23小时32分59秒自动关闭</div> -->
		<!-- status=10 为订单为已下单未支付  addtime:下单时间  auto_order_cancel=24 自动取消时间  -->
		<div id="order-detail-html"></div>
		<script type="text/x-dot-template" id="order-detail-tpl">
		<div class="orderBox" data-orderSn="{{=it.order_sn}}" data-price="{{=it.order_pay_price}}">
				{{ if( it.order_status == 1){ }}
					<div class="titleBox aui-flex-col aui-flex-between aui-flex-middle" id="top1">
						<div><img src="../../image/mine/m_icon17.png" class="icon" alt=""></div>
						<div class="flex-auto aui-font-size-14">等待买家付款</div>
						<div class="count_time" id="auto_order_cancel" mark="auto_order_cancel"	order_id="{{=it.order_id}}" status="{{=it.order_status}}" addtime="{{=it.order_addtime}}" auto_order_cancel="24">
								<span id="status_auto_order_cancel"></span>自动关闭
						</div>
					</div>
				{{ }else if( it.order_status == 2){ }}
					<div class="titleBox aui-flex-col aui-flex-between aui-flex-middle" id="top2"  title="待发货">
						<div><img src="../../image/mine/m_icon18.png" class="icon" alt=""></div>
						<div class="flex-auto aui-font-size-14">待发货</div>
						<div class="aui-font-size-12"></div>
					</div>
				{{ }else if( it.order_status == 3){ }}
					<div class="titleBox aui-flex-col aui-flex-between aui-flex-middle" id="top3" title="已发货" >
						<div><img src="../../image/mine/m_icon19.png" class="icon" alt=""></div>
						<div class="flex-auto aui-font-size-14">已发货</div>
						<div class="aui-font-size-12"></div>
					</div>
				{{ }else if( it.order_status == 4){ }}
					<div class="titleBox aui-flex-col aui-flex-between aui-flex-middle" id="top4" title="交易成功">
						<div><img src="../../image/mine/m_icon20.png" class="icon" alt=""></div>
						<div class="flex-auto aui-font-size-14">交易成功</div>
						<div class="aui-font-size-12"></div>
					</div>
				{{ }else if( it.order_status == -1){ }}
					<div class="titleBox aui-flex-col aui-flex-between aui-flex-middle" id="top5" title="关闭交易">
						<div><img src="../../image/mine/m_icon21.png" class="icon" alt=""></div>
						<div class="flex-auto aui-font-size-14">关闭交易</div>
						<div class="aui-font-size-12"></div>
					</div>
				{{ } }}
				<div class="black"></div>
				<div class="addrSec bg-white" tapmode onclick="change_add('address_win')">
					<div class="address aui-flex-row aui-flex-middle">
						<div class="aui-flex-col aui-flex-between">
							<div class="con">{{=it.order_rcv_name || ''}}</div>
							<div></div>
							<div class="aui-text-right">{{=it.order_rcv_mobile || ''}}</div>
						</div>
						<div class="addr">{{=it.order_rcv_province || ''}}{{=it.order_rcv_city || ''}}{{=it.order_rcv_district || ''}}{{=it.order_rcv_address || ''}}</div>
					</div>
				</div>
				<div class="shop bg-white">
					<div class="item">
						<div class=" aui-flex-col aui-flex-middle">
								<div class="media"><img src="{{=it.goods_cover}}" alt=""></div>
								<div class="flex-auto aui-padded-l-10 aui-padded-r-15">
									<div class="aui-font-size-12 color-000 aui-ellipsis-2">{{=it.goods_name}}</div>
									<div class="color-555 aui-font-size-10 aui-ellipsis" style="padding-top:0.25rem">{{=it.order_goods_spec_names}}</div>
									<div class="aui-flex-col aui-flex-between aui-flex-middle">
										<div class="aui-font-size-14 aui-padded-t-5 flex-auto">
										{{if(it.order_goods_type == 3){}}
											{{=it.order_pay_price}}积分
										{{ }else{}}
											¥{{=it.order_pay_price}}
										{{}}}
										<s></s>
										</div>
										<div class="aui-font-size-10 color-000">×{{=it.order_goods_count}}</div>
									</div>
								</div>
						</div>
					</div>
				</div>
				<div class="comBox bg-white">
					<div class="aui-border-t aui-border-b aui-py-5">
						<div class="comMode aui-flex-col aui-flex-between aui-flex-middle" id="pay1">
							<div class="color-333">商品金额</div>
							<div class="color-000">￥{{=it.order_pay_price}}</div>
						</div>
						<div class="comMode aui-flex-col aui-flex-between aui-flex-middle" id="pay2">
							<div class="color-333">运费</div>
							<div class="color-000">+￥{{=it.goods_shipping_price || '0.00'}}</div>
						</div>
					</div>
					<div class="comU aui-flex-col aui-flex-between aui-flex-middle color-000 aui-font-size-12">
						<div id="sPay" title="付款后显示">{{=it.order_status ==1 ? '需付款':'实付款（含运费）'}} </div>
						<div class="color-e7 aui-font-size-14 text-bold" id="price">￥{{=it.order_pay_price || ''}}</div>
					</div>
				</div>
			</div>
			<div class="">
			{{ if( it.order_status == 1){ }}
				<ul class="comBox info-list bg-white" id="info1" title="待付款">
					<li class="aui-flex-col aui-flex-between">
						<p class="ped-r-6">订单编号：</p>
						<input class="flex-auto color-555 aui-font-size-12" id="copySn" value="{{=it.order_sn}}" readonly="readonly">
						<button class="copy btn" tapmode onclick="copyVal(this)">复制</button>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">创建时间：</p>
						<p class="">{{=it.order_addtime || ''}}</p>
					</li>
				</ul>
			{{ }else if( it.order_status == 2){ }}
				<ul class="comBox info-list bg-white" id="info2" title="待发货">
					<li class="aui-flex-col aui-flex-between">
						<p class="ped-r-6">订单编号：</p>
						<input class="flex-auto color-555 aui-font-size-12" value="{{=it.order_sn}}" readonly="readonly">
						<button class="copy btn"  tapmode onclick="copyVal(this)">复制</button>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">下单时间：</p>
						<p class="">{{=it.order_addtime}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">付款时间：</p>
						<p class="">{{=it.order_pay_time}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">付款类型：</p>
						{{if(it.order_payment == 1){}}
						<p class="">微信支付</p>
						{{ }else if( it.order_payment == 2){ }}
						<p class="">支付宝支付</p>
						{{} else {}}
						<p class="">积分兑换</p>
						{{}}}
					</li>
				</ul>
			{{ }else if( it.order_status == 3){ }}
				<ul class="comBox info-list bg-white" id="info3" title="已发货">
					<li class="aui-flex-col aui-flex-between">
						<p class="ped-r-6">订单编号：</p>
						<input class="flex-auto color-555 aui-font-size-12" value="5284124586123556" readonly="readonly">
						<button class="copy btn" tapmode onclick="copyVal()">复制</button>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">下单时间：</p>
						<p class="">{{=it.order_addtime}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">付款时间：</p>
						<p class="">{{=it.order_pay_time}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">发货时间：</p>
						<p class="">{{=it.order_delivery_time}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">付款类型：</p>
						{{if(it.order_payment == 1){}}
						<p class="">微信支付</p>
						{{ }else if( it.order_payment == 2){ }}
						<p class="">支付宝支付</p>
						{{} else {}}
						<p class="">积分兑换</p>
						{{}}}
					</li>
				</ul>
			{{ }else if( it.order_status == 4){ }}
				<ul class="comBox info-list bg-white" id="info4" title="交易成功">
					<li class="aui-flex-col aui-flex-between">
						<p class="ped-r-6">订单编号：</p>
						<input class="flex-auto color-555 aui-font-size-12" value="{{=it.order_sn}}" readonly="readonly">
						<button class="copy btn" tapmode onclick="copyVal()">复制</button>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">下单时间：</p>
						<p class="">{{=it.order_addtime}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">付款时间：</p>
						<p class="">{{=it.order_pay_time}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">发货时间：</p>
						<p class="">{{=it.order_delivery_time}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">收货时间：</p>
						<p class="">{{=it.finish_time}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">付款类型：</p>
						{{if(it.order_payment == 1){}}
						<p class="">微信支付</p>
						{{ }else if( it.order_payment == 2){ }}
						<p class="">支付宝支付</p>
						{{} else {}}
						<p class="">积分兑换</p>
						{{}}}
					</li>
				</ul>
			{{ }else if( it.order_status == -1){ }}
				<ul class="comBox info-list bg-white" id="info5" title="交易关闭">
					<li class="aui-flex-col aui-flex-between">
						<p class="ped-r-6">订单编号：</p>
						<input class="flex-auto color-555 aui-font-size-12" value="{{=it.order_sn}}" readonly="readonly">
						<button class="copy btn" tapmode onclick="copyVal()">复制</button>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">创建时间：</p>
						<p class="">{{=it.order_addtime || ''}}</p>
					</li>
					<li class="aui-flex-col">
						<p class="ped-r-6">关闭时间：</p>
						<p class="">{{=it.order_cancel_time || ''}}</p>
					</li>
				</ul>
			{{ } }}

			</div>
			<div style="height:4rem"></div>
			{{ if( it.order_status == 1){ }}
				<footer class="aui-flex-col aui-flex-middle aui-flex-right footerBox" id="footer1" title="待发货">
						<div class="fotBtn" tapmode onclick="closeOrder()">取消订单</div>
						{{if(it.order_goods_type == 3){}}
						<div class="fotBtn on" tapmode onclick="openUction()">兑换</div>
						{{ }else {}}
							<div class="fotBtn on" tapmode onclick="openPay()">付款</div>
						{{}}}
				</footer>
			{{ }else if( it.order_status == 2){ }}

			{{ }else if( it.order_status == 3){ }}
				<footer class="aui-flex-col aui-flex-middle aui-flex-right footerBox" id="footer2" title="已发货">
						<div class="fotBtn" tapmode onclick="openWin('logistics_detail_win')">查看物流</div>
						<div class="fotBtn on" tapmode onclick="confirmShop()">确认收货</div>
				</footer>
			{{ }else if( it.order_status == 4){ }}
				<footer class="aui-flex-col aui-flex-middle aui-flex-right footerBox" id="footer3" title="交易成功">
						<div class="fotBtn" tapmode onclick="openWin('logistics_detail_win')">查看物流</div>
				</footer>
			{{ }else if( it.order_status == -1){ }}
				<footer class="aui-flex-col aui-flex-middle aui-flex-right footerBox" id="footer4" title="交易关闭">
						<div class="fotBtn" tapmode onclick="delOrder()">删除订单</div>
				</footer>
			{{ } }}




		</script>
</body>
<script type="text/javascript" src="../../script/import.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
var closeTxt;
var confirm;
var ORDER_ID;
apiready = function() {
		ORDER_ID = api.pageParam.ORDER_ID;
		getOrderDetail();
		api.parseTapmode();
};
function getOrderDetail(){
	ORDER_ID = api.pageParam.ORDER_ID;
		api.ajax({
		    url: BASE_URL_2 + 'App/Mall/orderDetail',
		    method: 'post',
		    data: {
		        values: {
							id: ORDER_ID,
							userid: getUserId()
		        }
		    }
		},function(ret, err){
			console.log(JSON.stringify(ret))
		    if (ret && ret.code == 1) {
					var tpl = $$('#order-detail-tpl').html();
					var tempFn = doT.template(tpl);
					$$('#order-detail-html').html(tempFn(ret.data));
					var val = $$('#auto_order_cancel').attr("mark");
					var status = $$('#auto_order_cancel').attr("status");
					// $$("div[id^=auto_order_cancel]").each(function(index, element) {
						//  var val = $$(this).attr("mark");
						//  var status = $$(this).attr("status");
						 timeCount(val,status);
				//  });
		    } else {
					// $$('.notData').removeClass('aui-hide');
		    }
		});

}

// 取消订单
function closeOrder(el){
	ORDER_ID = api.pageParam.ORDER_ID;
	api.ajax({
			url: BASE_URL_2 + 'App/Mall/orderCancel',
			method: 'post',
			data: {
					values: {
							id: ORDER_ID,
							userid: getUserId()
					}
			}
	},function(ret, err){
			if (ret && ret.code == 1) {
				api.sendEvent({
				    name: 'cancelEvent',
				});
				setTimeout(function(){
					api.closeWin();
				},500)
				toast(ret.msg)
			} else {
					toast(ret.msg)
			}
	});

}
function copyVal(el) {
	var clipBoard = api.require('clipBoard');
	var value = $$(el).prev().val();
	clipBoard.set({
			value:value
	}, function(ret, err) {
			if (ret) {
					toast('快递单号复制成功')
			} else {
					alert(JSON.stringify(err));
			}
	});
}
// 头部确认付款倒计时
function timeCount(remain_id,status){
		 function _fresh(){
				 var nowDate = new Date();//当前时间
				 log(nowDate)
				 var id=$$('#'+remain_id).attr("order_id"); //当前订单的id
				 var status=$$('#'+remain_id).attr("status"); //当前订单的id
				 var addTime = new Date($$('#'+remain_id).attr('addTime'));//下单开始时间
				 var auto_order_cancel = $$('#'+remain_id).attr('auto_order_cancel');//订单支付有效时长
				 var auto_totalS = parseInt(auto_order_cancel*60*60);
				 var ad_totalS = parseInt((addTime.getTime()/1000)+auto_totalS);  ///下单总秒数
				 var totalS = parseInt(ad_totalS-(nowDate.getTime()/ 1000));///支付时长
				 if(status){
						 if(totalS > 0){
								 var _hour   = retDate(parseInt((totalS / 3600) % 24));
								 var _minute = retDate(parseInt((totalS / 60) % 60));
								 var _second = retDate(parseInt(totalS % 60));
								 $$('#status_'+remain_id).html('剩余'+_hour+'时'+_minute+'分'+_second+'秒');
						 }else{//支付超时
								//  $$('#status_'+remain_id).html('');
								 clearInterval(sh);
									api.sendEvent({
									    name: 'cancelEvent',
									});
									getOrderDetail();
							}
				 }
		 }
		 _fresh();
		 var sh = setInterval(_fresh,1000);
 }
 // 如果倒计时小于10，就返回0
 function retDate(i){
	 if(i < 10){
		 i = '0' + i
	 }
	 return i;
 }
 // 删除订单
 function delOrder(el){
	 ORDER_ID = api.pageParam.ORDER_ID;
	 var confirmMaskTxt = ['确认删除订单？','取消','确认删除'];
	 openConfirmMask(confirmMaskTxt,'del('+ORDER_ID+')');
 }
 function del(Id){
	 api.ajax({
		 url: BASE_URL_2 + 'App/Mall/orderDelete',
		 method: 'post',
		 data: {
			 values: {
				 id: Id,
				 userid: getUserId()
			 }
		 }
	 },function(ret, err){
		 console.log(JSON.stringify(ret))
		 if (ret) {
			 if(ret.code == 1){
				 toast(ret.msg);
				 api.execScript({
				     name: 'order1_win',
				     frameName: 'order1_frm',
				     script: 'getOrderList();'
				 });
				 setTimeout(function(){
					 api.closeWin()
				 },500)
			 }else{
				 toast(ret.msg);
			 }
		 }
	 });
 }
 function openPay(el){
	 var price = $$('.orderBox').data('price');
	 var orderSn = $$('.orderBox').data('orderSn');
	 api.openFrame({
		 name:'mask_pay',
		 url:'widget://html/mask_pay.html',
		 rect: {
			 x: 0,
			 y: 0,
			 w: 'auto',
			 h: 'auto'
		 },
		 animation: {
			 type: 'fade',
			 duration:300
		 },
		 pageParam: {
			 price: price,
			 orderSn: orderSn
		 }
	 })
 }
 function openUction(){
	 ORDER_ID = api.pageParam.ORDER_ID;
	 api.openWin({
			 name: 'Uorder_confirm_win',
			 url: '../giftBag/Uorder_confirm_win.html',
			 pageParam:{
				 orderId: ORDER_ID
			 }
	 });
 }
// 	// 修改地址
// 	function change_add(url) {
// 		api.openWin({
// 			name: url,
// 			url: url + '.html'
// 		});
// 	}
// 确认收货
function confirmShop(el){
	ORDER_ID = api.pageParam.ORDER_ID;
	var confirmMaskTxt = ['您确认已收到商品？确认收货后，订单交易完成。','取消','确认'];
	openConfirmMask(confirmMaskTxt,'confirm('+ ORDER_ID +')');
}
function confirm(Id){
	api.ajax({
		url: BASE_URL_2 + 'App/Mall/orderFinish',
		method: 'post',
		data: {
			values: {
				id: Id,
				userid: getUserId()
			}
		}
	},function(ret, err){
		console.log(JSON.stringify(ret))
		if (ret) {
			if(ret.code == 1){
				toast(ret.msg);
				setTimeout(function(){
					api.closeWin()
				},500)
			}else{
				toast(ret.msg);
			}
		}
	});
}
</script>

</html>
